# Maintainer: Andrzej Giniewicz <gginiu@gmail.com>
# Contributor: Cristóvão D. Sousa <crisjss@gmail.com>
pkgname=dsdp
pkgver=5.8
pkgrel=7
pkgdesc="A free open source implementation of an interior-point method for semidefinite programming"
arch=('loong64' 'x86_64')
url="https://www.mcs.anl.gov/hs/software/DSDP"
license=('custom')
depends=("lapack")
source=("https://www.mcs.anl.gov/hs/software/${pkgname^^}/${pkgname^^}$pkgver.tar.gz"
        "make.include.patch")
md5sums=('37c15a3c6c3f13e31262f65ac4364b5e'
         'd90d4bf5ce00f6f86722db2624675ae5')
sha256sums=('26aa624525a636de272c0b329e2dfd01a0d5b7827f1c1c76f393d71e37dead70'
            'e621419ff3952204a527d49b5081e9eb75071cccfda3d0a04900a597ee81203d')

build() {
  cd "$srcdir/${pkgname^^}$pkgver"

  patch make.include < "$srcdir/make.include.patch"

  CFLAGS+=' -ffat-lto-objects' \
  make DSDPROOT="$srcdir/${pkgname^^}$pkgver" dsdpapi
}

package() {
  cd "$srcdir/${pkgname^^}$pkgver"
  
  install -d "$pkgdir"/usr/{lib,include/dsdp}
  install -Dm755 bin/dsdp5 "$pkgdir"/usr/bin/dsdp5
  install -Dm644 lib/* "$pkgdir"/usr/lib/
  install -Dm644 include/*.h "$pkgdir"/usr/include/dsdp/
  install -Dm644 dsdp-license "$pkgdir"/usr/share/licenses/$pkgname/dsdp-license
}
